package io;

import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class Test2 {
    public static void main(String[] args) throws IOException {
        FileOutputStream fos = new FileOutputStream("fos.txt",true);
        Scanner scanner = new Scanner(System.in);
        while(true){
            System.out.print("请输入写入内容：");
            String data = scanner.next();
            if ("exit".equals(data)){
                System.out.println("退出");
                break;
            }
            fos.write(data.getBytes(StandardCharsets.UTF_8));
        }
        System.out.println("写出完成");
        fos.close();
    }
}
